package com.autumn.jvm.jvm;

/**
 * @author: Autumn
 * @describe:
 * @date: 2022/10/7
 * @modified By:
 */
public class ReferenceCountingGC {
    Object instance = null;

    public static void main(String[] args) {
        ReferenceCountingGC objA = new ReferenceCountingGC();//objA计数器为1
        ReferenceCountingGC objB = new ReferenceCountingGC();//objB计数器为1
        objA.instance = objB;   //objB计数器+1为2
        objB.instance = objA;   //objA计数器+1为2
        objA = null;            //objA计数器-1为1
        objB = null;            //objB计数器-1为1
    }
}
